package com.pr.makfilm.core.cmp.web;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.IChoiceRenderer;
import org.apache.wicket.model.IModel;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: Pawel
 * Date: 24.09.13
 * Time: 23:54
 * To change this template use File | Settings | File Templates.
 */
public class BootstrapDropDownPanel<T> extends AbstractBootstrapComponent
{
   private DropDownChoice<T> dropDownChoice;

   public BootstrapDropDownPanel(String id, IModel<T> model, IModel<List<T>> listModel, IChoiceRenderer<T> renderer)
   {
      super(id);
      dropDownChoice = new DropDownChoice<T>("dropdown", model, listModel, renderer);
      container.add(dropDownChoice);
   }

   public BootstrapDropDownPanel(String id, IModel<T> model, IModel<List<T>> listModel)
   {
      this(id, model, listModel, null);
   }

   @Override
   public void setValidation(boolean required)
   {
      dropDownChoice.setRequired(required);
   }

   @Override
   public Component getField()
   {
      return dropDownChoice;
   }
}
